package ctrip.utils

import java.text.SimpleDateFormat
import java.util.Date

/**
 * Created by gongenbo on 2017/5/22.
 */
object TimeUtils {
  def dateToStamp(s: String): String = {
    val simpleDateFormat: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")
    var date: Date = new Date
    try {
      date = simpleDateFormat.parse(s)
    }
    catch {
      case e: Exception => {
        e.printStackTrace
      }
    }
    val ts: Long = date.getTime / 1000
    String.valueOf(ts)
  }

  def main(args: Array[String]) {
    print("时间戳：" + dateToStamp("2013-04-14"))
  }
}
